<?php 
/* 
Template Name: Homepage
*/
?>

<?php global $data; ?>
<?php get_header(); ?>

<!-- BEGIN #main-content -->
<div <?php echo sidebar_position('primary-content'); ?>>

	<?php /* ----------------------------------------------------
			Slideshow Loop
	------------------------------------------------------- */ ?>
	
	<?php if( $data['slideshow_display'] ) { ?>
		
		<?php $slide_limit = ''; ?>
		<?php $slide_cat = ''; ?>
		
		<?php if( $data['slideshow_max_slides'] ) { $slide_limit = '&posts_per_page=' . $data['slideshow_max_slides']; } ?>
		<?php if( $data['slideshow_category'] ) { $slide_cat = '&cat=' . $data['slideshow_category']; } ?>
		
		<?php query_posts( "post_type=post" . $slide_limit . $slide_cat ); ?>
		<?php if ( have_posts() ) : ?>
			<div class="slider clearfix">
				<ul class="slides">
					<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'loop', 'style3' ); ?>
					<?php endwhile; ?>
				</ul>
			</div>
		<?php endif; ?>
		<div class="clearboth"></div>
	
	<?php } ?>
	
	<?php /* ----------------------------------------------------
			Two Large Columns Loop
	------------------------------------------------------- */ ?>
	
	<?php if( $data['home2cols_display'] ) { ?>
		
		<?php $home2cols_col1_cat = ''; ?>
		<?php $home2cols_col2_cat = ''; ?>
		
		<?php if( $data['home2cols_col1_cat'] ) { $home2cols_col1_cat = '&cat=' . $data['home2cols_col1_cat']; } ?>
		<?php if( $data['home2cols_col2_cat'] ) { $home2cols_col2_cat = '&cat=' . $data['home2cols_col2_cat']; } ?>
		
		<ul class="news-block-columns-2 clearfix">

			<?php query_posts( "post_type=post&posts_per_page=1" . $home2cols_col1_cat ); ?>
			<?php if ( have_posts() ) : ?>
					<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'loop', 'style6' ); ?>
					<?php endwhile; ?>
			<?php endif; ?>
			
			<?php query_posts( "post_type=post&posts_per_page=1" . $home2cols_col2_cat ); ?>
			<?php if ( have_posts() ) : ?>
					<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'loop', 'style6' ); ?>
					<?php endwhile; ?>
			<?php endif; ?>
	
		</ul>
	
	<?php } ?>
	
	<?php /* ----------------------------------------------------
			Five Small Columns Loop
	------------------------------------------------------- */ ?>
	
	<?php if( $data['home5cols_display'] ) { ?>
		
		<?php $home5cols_cat = ''; ?>
		<?php $home5cols_limit = ''; ?>
		
		<?php if( $data['home5cols_cat'] ) { 
			$home5cols_cat = '&cat=' . $data['home5cols_cat']; 
			$thecat = get_category($data['home5cols_cat']);
			$category_name1 = $thecat->name;
		} else {
			$category_name1 = __('All','qns');
		} ?>
		
		<?php if( $data['home5cols_limit'] ) { $home5cols_limit = '&posts_per_page=' . $data['home5cols_limit']; } ?>
		
		<div class="title-block">
			<h3><?php echo $category_name1; ?></h3>
		</div>

		<?php query_posts( "post_type=post" . $home5cols_cat . $home5cols_limit ); ?>
		<?php if ( have_posts() ) : ?>
			<ul class="news-block-columns-5 clearfix">
				<?php while ( have_posts() ) : the_post(); ?>
					<?php get_template_part( 'loop', 'style4' ); ?>
				<?php endwhile; ?>
			</ul>
		<?php endif; ?>
	
	<?php } ?>
	
	<?php /* ----------------------------------------------------
			Two Column Mini Slideshow Loop
	------------------------------------------------------- */ ?>
	
	<?php if( $data['home2cols_slide_display'] ) { ?>
		
		<?php $home2cols_slide_col1_cat = ''; ?>
		<?php $home2cols_slide_col2_cat = ''; ?>
		<?php $home2cols_slide_col1_limit = ''; ?>
		<?php $home2cols_slide_col2_limit = ''; ?>
		
		<?php if( $data['home2cols_slide_col1_cat'] ) { 
			$home2cols_slide_col1_cat = '&cat=' . $data['home2cols_slide_col1_cat']; 
			$thecat = get_category($data['home2cols_slide_col1_cat']);
			$category_name2 = $thecat->name;
		} else {
			$category_name2 = __('All','qns');
		} ?>
		
		<?php if( $data['home2cols_slide_col2_cat'] ) { 
			$home2cols_slide_col2_cat = '&cat=' . $data['home2cols_slide_col2_cat']; 
			$thecat = get_category($data['home2cols_slide_col2_cat']);
			$category_name3 = $thecat->name;
		} else {
			$category_name3 = __('All','qns');
		} ?>
		
		<?php if( $data['home2cols_slide_col1_limit'] ) { $home2cols_slide_col1_limit = '&posts_per_page=' . $data['home2cols_slide_col1_limit']; } ?>
		<?php if( $data['home2cols_slide_col2_limit'] ) { $home2cols_slide_col2_limit = '&posts_per_page=' . $data['home2cols_slide_col2_limit']; } ?>
		
		<!-- BEGIN .shop-block-columns-2 -->
		<ul class="shop-block-columns-2 clearfix">
			
			<!-- BEGIN .shop-block-col-2 -->
			<li class="shop-block-col-2">
	
				<div class="title-block">
					<h3><?php echo $category_name2; ?></h3>
				</div>
			
				<?php query_posts( "post_type=post" . $home2cols_slide_col1_cat . $home2cols_slide_col1_limit ); ?>
				<?php if ( have_posts() ) : ?>
					<div class="slider-news clearfix">
						<ul class="slides">	
							<?php while ( have_posts() ) : the_post(); ?>
								<?php get_template_part( 'loop', 'style5' ); ?>
							<?php endwhile; ?>
						</ul>
					</div>		
				<?php endif; ?>
		
			<!-- END .shop-block-col-2 -->
			</li>
		
			<!-- BEGIN .shop-block-col-2 -->
			<li class="shop-block-col-2">
			
				<div class="title-block">
					<h3><?php echo $category_name3; ?></h3>
				</div>
			
				<?php query_posts( "post_type=post" . $home2cols_slide_col2_cat . $home2cols_slide_col2_limit ); ?>
				<?php if ( have_posts() ) : ?>
					<div class="slider-news clearfix">
						<ul class="slides">	
							<?php while ( have_posts() ) : the_post(); ?>
								<?php get_template_part( 'loop', 'style5' ); ?>
							<?php endwhile; ?>
						</ul>
					</div>			
				<?php endif; ?>
	
			<!-- END .shop-block-col-2 -->
			</li>
		
		<!-- END .shop-block-columns-2 -->
		</ul>
	
	<?php } ?>
	
	<?php /* ----------------------------------------------------
			Shop Loop
	------------------------------------------------------- */ ?>
	
	<?php if(is_plugin_active('woocommerce/woocommerce.php')) { ?>
	
	<?php if( $data['shop_display'] ) { ?>
		
		<?php $homeshop_category = ''; ?>
		<?php $homeshop_per_page = ''; ?>
		
		<?php if( $data['homeshop_category'] ) { $homeshop_category = 'category="' . $data['homeshop_category'] . '"'; } ?>
		<?php if( $data['homeshop_per_page'] ) { $homeshop_per_page = 'per_page="' . $data['homeshop_per_page'] . '"'; } ?>
		<?php if( $data['homeshop_title'] ) { $homeshop_title = $data['homeshop_title']; } else { $homeshop_title = __('Our Shop','qns'); } ?>
	
		<div class="title-block">
			<h3><?php echo $homeshop_title; ?></h3>
		</div>
	
		<div class="featured-products-4">
			<?php echo do_shortcode('[product_category ' . $homeshop_category . ' columns="4" ' . $homeshop_per_page . ']'); ?>
		</div>
	
	<?php } ?>
	
	<?php } ?>
		
<!-- BEGIN #main-content -->
</div>

<?php get_sidebar(); ?>
<?php get_footer(); ?>